package supe;

import java.util.Scanner;

public class StudyMath {
    Scanner sc = new Scanner(System.in);
    public void sqrt() {
        System.out.println("输入一个非负数x:");
        int a = sc.nextInt();
        if (a > 0) {
            double x = Math.sqrt(a);
            int res = (int) x;
            System.out.println("平方取根取整后为" + res);
            }
        }
        public void task2() {
            System.out.println("输入n");
            int n = sc.nextInt();
            int f = 1;
            if (n >= 0) {
                if (n == 0) {
                    System.out.println("结果为" + 1);
                } else {
                    for (int i = n; i >= 1; i--) {
                        f *= i;
                    }
                    System.out.println("结果为" + f);
                }
            } else {
                System.out.println("输出错误");
            }
        }

    public void task3() {
            System.out.println("输入一个num:");
            int num = sc.nextInt();
            if (num > 0){
                double s = Math.sqrt(num);
                int res = (int)s;
                int m = res * res;
                if (m == num){
                    System.out.println("true");
                }else {
                    System.out.println("false");
                }
            }else {
                System.out.println("输入错误");
            }
        }
    public static void main(String[] args){
       StudyMath yz = new StudyMath();
       yz.sqrt();
       yz.task2();
       yz.task3();
    }

}
